const compose = require('koa-compose')
const glob = require('glob');


registerRouter = () => {
  let routers = [];
  glob.sync((__dirname.replace(/\\/g,'/')+'/*.js'))
  .filter(value =>(value.indexOf('index.js')===-1))
  .forEach(router=>{
    console.log(router)
    routers.push(require(router).routes())
    routers.push(require(router).allowedMethods())
  })
  return compose(routers)
}

module.exports = registerRouter
